class ParticleGenerator{
  //LinkedList particles;
  ArrayList <Particle>particles; 
  float x,y,z, radius, ptRadius;
  pt center,temp,temp1;
  vec v, I,J;
  
  ParticleGenerator(){
   // LinkedList particles= new LinkedList();
    particles = new ArrayList<Particle>(5000);
    //x=myCurve.pts.get(0).x;
    //y=myCurve.pts.get(0).y;
    //z=myCurve.pts.get(0).z;
    radius=50;
    center=new pt(myCurve.pts.get(0).x,myCurve.pts.get(0).y,myCurve.pts.get(0).z);
    ptRadius=5; 
   } 
   void generateParticles(){
     //make vector from center with magnitude radius
     //direction is random
    for(int i=0;i<50;i++){
     float phi=random(0,2*PI);
     float theta=random(0,PI);
     float xPart=radius*cos(theta);
     float yPart=radius*sin(theta)*cos(phi);
     float zPart=radius*sin(theta)*sin(phi);
     v= new vec();
     v=V(new pt(0,0,0),center);
     Particle particle=new Particle(new pt(xPart,yPart,zPart),new vec());
     particle.setPt(particle.getPt().add(v));
       if(createParticle(particle))
     particles.add(particle);
    }
   }
   void setCenter(pt p){
     this.center = p;
   }
   void setX(float x1){
     this.center.x=x1;
   }
   void setY(float y1){
      this.center.y=y1; 
   
   }
   void setZ(float z1){
      this.center.z=z1; 
   }
   void setRadius(float radius1){
      this.radius= radius1; 
     
   }
   void setPtRadius(float ptRadius1){
     this.ptRadius=ptRadius1; 
   }
   String toString(){
      String ret="";
      for(int i=0;i<particles.size();i++){
        ret+=("Points: "+particles.get(i)+"\n");
     }
     return ret;
   }
   boolean createParticle(Particle B){
     if(particles.size()==0)
       return true;
     for(int i=0;i<particles.size();i++){ 
     if(particles.get(i).intersects(B))
         return false;
      
     }
    return true;
   }
   void drag(vec v){
    center.add(v); 
     
   }
   void deleteFromCurve(Curve c){//Need to delete points from list once they are a certain distance away from the last point
     for(int i=0; i<particles.size();i++){
    // if(dist(particles.get(i).x,particles.get(i).y,particles.get(i).z,myCurve.pts.get(myCurve.pts.size()-1))>50))
       particles.remove(i);
     }
   }
   void draw(){
      pushMatrix();
      stroke(black);
      noFill();
      translate(center.x,center.y,center.z); 
      sphereDetail(15,15);
      sphere(radius);
      popMatrix();
     
   }

}
